package com.sk.sourcecircle.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sk.sourcecircle.R;
import com.sk.sourcecircle.entity.OrderListBean;
import com.sk.sourcecircle.utils.MyUtils;

import java.util.List;

/**
 * Created by sk on 2017/12/27.
 */

public class OrderListAdapter extends BaseQuickAdapter<OrderListBean.DataBean,BaseViewHolder> {


    public OrderListAdapter(int layoutResId, @Nullable List<OrderListBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderListBean.DataBean item) {
        helper.setText(R.id.tv_status,item.getStatus_name())
                .setText(R.id.tv_content,item.getActivity_name())
                .setText(R.id.group_name,item.getCommunity_name())
                .setText(R.id.event_location,item.getDistrict() +" "+item.getAddress())
                .setText(R.id.tv_time, MyUtils.stampToDate(item.getStart_time())+"开始");
        Glide.with(mContext).load(item.getImg_url()).into((ImageView) helper.getView(R.id.item_bg));

        if(Double.parseDouble(item.getOrder_price())>0){

            helper.setText(R.id.tv_price,"￥"+item.getOrder_price()).setTextColor(R.id.tv_price, Color.parseColor("#ff5050"));

        }else {
            helper.setText(R.id.tv_price,"免费").setTextColor(R.id.tv_price, Color.parseColor("#219021"));

        }

    }
}
